package com.xzz.cloud.alibaba.controller;

import com.xzz.cloud.alibaba.service.StorageService;
import com.xzz.cloud.entity.CommonResult;
import com.xzz.cloud.entity.Order;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: hhz
 * @createDate: 2021-4-6
 */
@RestController
public class StorageController {
    @Resource
    private StorageService storageService;

    @PostMapping("/storage/decrease")
    public CommonResult decrease(@RequestBody Order order) {
        storageService.decrease(order.getProductId(),order.getCount());
        return new CommonResult(200, "扣减库存成功!");
    }
}
